#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

typedef struct friend
{
	char name[10];
	int birth;
	char tele[25];
}Friend;

void sort(Friend *friends,int n)
{
	Friend temp;
	int i = 0;
	int j = 0;
	for(i=0;i<n-1;i++)
		for(j=0;j<n-i-1;j++)
			if (friends[j].birth > friends[j + 1].birth)
			{
				temp = friends[j];
				friends[j] = friends[j + 1];
				friends[j + 1] = temp;
			}
}

void print_struct(Friend *friends,int n)
{
	int i = 0;
	for (i = 0;i < n;i++)
	{
		printf("%s ", friends[i].name);
		printf("%d ", friends[i].birth);
		printf("%s\n", friends[i].tele);
	}
}



int main()
{
	int i = 0;
	int n = 0;
	Friend friends[10];
	scanf("%d", &n);
	for (i = 0;i < n;i++)
	{
		scanf("%s", friends[i].name);
		scanf("%d", &friends[i].birth);
		scanf("%s", friends[i].tele);
	}
	sort(friends,n);
	print_struct(friends,n);
	return 0;
}